/**
 * 匹配规则组件相关配置重写函数
 */

import type { IMatchConfig, MatchField } from '@/components/MatchingRule/types'

// 重写转换规则模块里面匹配规则的配置
export function rewriteTransformRuleModuleConfigure(arr: IMatchConfig[]) {
  console.log('arr: ', arr)
  const keys: MatchField[] = [
    'http.host',
    'http.referer',
    'http.request.full_uri',
    'http.request.uri.path',
    'http.request.uri.query',
    'http.user_agent'
  ]
  arr.forEach((item) => {
    if (item.value === 'http.request.uri.query') {
      item.field.placeholder = '示例：?page=1234'
    }
    if (keys?.includes(item.value)) {
      item.operatorOptions = item.operatorOptions.filter(
        (op) => !['in', 'not_in'].includes(op.value)
      )
      console.log('item.operatorOptions: ', item.value, item.operatorOptions)
    }
  })
  return arr
}
